﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ThucThe;
using System.Data;

namespace KetNoi
{
    public class HopDong_ketnoi
    {
        clsKetNoi kn = new clsKetNoi();
        public DataTable danhsachhopdong()
        {
            return kn.LayDuLieu("HopDong_load");
        }
        public int Them_HopDong(HopDong_thucthe hd)
        {
            int Nparameter = 4;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@maKhachHang"; value[0] = hd.MaKhachHang;
            name[1] = "@maNhanvien"; value[1] = hd.MaNhanVien;
            name[2] = "@maTour"; value[2] = hd.MaTour;
            name[3] = "@ngayTao"; value[3] = hd.NgayTao;
            return kn.CapNhat("HopDong_them", name, value, Nparameter);
        }
        public int Sua_HopDong(HopDong_thucthe hd)
        {
            int Nparameter = 5;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@maHopDong"; value[0] = hd.MaHopDong;
            name[1] = "@maKhachHang"; value[1] = hd.MaKhachHang;
            name[2] = "@maNhanvien"; value[2] = hd.MaNhanVien;
            name[3] = "@maTour"; value[3] = hd.MaTour;
            name[4] = "@ngayTao"; value[4] = hd.NgayTao;
            return kn.CapNhat("HopDong_sua", name, value, Nparameter);
        }
        public int Xoa_HopDong(HopDong_thucthe hd)
        {
            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@maHopDong";
            value[0] = hd.MaHopDong;
            return kn.CapNhat("HopDong_xoa", name, value, Nparameter);
        }
        public DataTable Tim_HopDomg(KhachHang_thucthe kh)
        {
            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@tenKhachHang";
            value[0] = kh.TenKhachHang;
            return kn.TimKiem("HopDong_tim", name, value, Nparameter);
        }
    }
}
